<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

$this->useClass("Handler_Community");
class Action_Community_RssFeedDelete extends Handler_Community {
  public function process() {
    $aa = $this->aa;
		$acl_data = $aa->getInfo();
		if (!$aa->is_granted('community_edit')) return;
    
    if ( isset($this->params['oid']) && !empty($this->params['oid']) ) {
      $object = $this->ctx->store->getObject($this->params['oid']);
      $object->is_deleted = 1;
      $object->save();
      
      $this->rh->setMessage('Подписка удалена.');
    }

    $theme = 0;
    if ( isset($this->rh->GET['theme']) && !empty($this->rh->GET['theme']) ) {
      $theme = (integer) abs($this->rh->GET['theme']+0);
    }
    
    if ( $theme > 0 ) {
      $location = "{$this->aa->acl_data['base_url']}/{$acl_data['community_url']}/theme/{$theme}";
    } else {
      $location = "{$this->aa->acl_data['base_url']}/{$acl_data['community_url']}/rss_list";
    }
    
    if ( isset($this->rh->GET['lpage']) && !empty($this->rh->GET['lpage']) ) {
      $lpage = (integer) abs($this->rh->GET['lpage']+0);
      if ( $lpage > 0 ) {
        $location .= "?lpage={$lpage}";
      }
    } else if ( isset($this->rh->GET['show_all']) && !empty($this->rh->GET['show_all']) ) {
      $location .= "?show_all=1";
    }
    header('Location: ' . $location);
    exit;
  }
}